<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Repositories\OrderRepo;


class OrderController extends BaseController
{
    protected $orderRepo;

    public function _initialize()
    {
        $this->orderRepo = new OrderRepo();
    }
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $pageSize =  $request->pageSize ? $request->pageSize : 10;
        $where = [];
        $where['sn'] = $request->sn;
        $where['state']  = $request->state;
        if($request->date_time) {
            $where['date_time'] = $request->date_time;
        }
        $data = $this->orderRepo->getOrderList($where,$pageSize);

        return $this->sucRes(200,$data);
    }

    public function del(Request $request) 
    {
        $order_id = $request->id;
        $this->orderRepo->delOrder($order_id);
        return $this->sucRes(200);
    }
    public function send(Request $request)
    {
        $order_id = $request->id;
        $this->orderRepo->setSend($order_id);
        return $this->sucRes();
    }
    public function detail(Request $request)
    {
        $order_id = $request->id;
        $data =  $this->orderRepo->getDetail($order_id);
        return $this->sucRes(200,$data);
    }
}